import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

// 路由懒加载
const Index = (resolve) => {
  import('@/components/index/index').then((module) => {
    resolve(module)
  })
}
const Find = (resolve) => {
  import('@/components/find/find').then((module) => {
    resolve(module)
  })
}
const Mine = (resolve) => {
  import('@/components/mine/mine').then((module) => {
    resolve(module)
  })
}
const login = (resolve) => {
  import('@/components/login/login').then((module) => {
    resolve(module)
  })
}
const BookDetail = (resolve) => {
  import('@/components/base/book-detail/book-detail').then((module) => {
    resolve(module)
  })
}
const BookDetailCity = (resolve) => {
  import('@/components/base/book-detail-city/book-detail-city').then((module) => {
    resolve(module)
  })
}
const Chapter = (resolve) => {
  import('@/components/index/book-chapter').then((module) => {
    resolve(module)
  })
}
const Question = (resolve) => {
  import('@/components/index/question').then((module) => {
    resolve(module)
  })
}
const Sift = (resolve) => {
  import('@/components/sift/sift').then((module) => {
    resolve(module)
  })
}

const EditUserInfo = (resolve) => {
  import('@/components/mine/edit-user-info').then((module) => {
    resolve(module)
  })
}

const StudentList = (resolve) => {
  import('@/components/mine/student-list').then((module) => {
    resolve(module)
  })
}

const EditStudent = (resolve) => {
  import('@/components/mine/edit-student').then((module) => {
    resolve(module)
  })
}

const EditAddress = (resolve) => {
  import('@/components/mine/edit-address').then((module) => {
    resolve(module)
  })
}

const BindPhone = (resolve) => {
  import('@/components/login/bind-phone').then((module) => {
    resolve(module)
  })
}

let router = new Router({
  routes: [
    // 根路径
    {
      path: '/',
      redirect: '/find',
      component: Find
    },
    // 首页
    {
      path: '/index',
      component: Index
    },
    // 登录
    {
      path: '/login',
      component: login
    },
    // 书城
    {
      path: '/find',
      component: Find
    },
    // 我的
    {
      path: '/mine',
      component: Mine
    },
    // 书籍详情
    {
      path: '/bookdetail',
      component: BookDetail
    },
    // 书籍详情
    {
      path: '/bookdetailcity',
      component: BookDetailCity
    },
    // 章节详情
    {
      path: '/chapter',
      component: Chapter
    },
    // 问题列表
    {
      path: '/question',
      component: Question
    },
    // 精选
    {
      path: '/sift',
      component: Sift
    },
    // 学生列表
    {
      path: '/student-list',
      component: StudentList
    },
    // 编辑学生
    {
      path: '/edit-student',
      component: EditStudent
    },
    {
      path: '/EditUserInfo',
      component: EditUserInfo
    },
    {
      path: '/EditAddress',
      component: EditAddress
    }
    , {
      path: '/BindPhone',
      component: BindPhone
    }
  ]
})

export default router
